//
// Created by Tony on 2024/5/24.
//

#ifndef PARSER_VAR_DEF_STMT_H
#define PARSER_VAR_DEF_STMT_H

#include "../../AstList.h"
#include "../../leaf/Name.h"
#include "../TypeTag.h"

namespace Parser {

class VarDefStmt final : public AstList {
    string nodeName;
    shared_ptr<Name> varName;
    shared_ptr<TypeTag> typeTag;
    shared_ptr<Ast> initExpr;
    Compiler::Location location;
    Compiler::Symbol mSymbol;

public:
    VarDefStmt() : AstList({}) { nodeName = __func__; }

    void setName(const shared_ptr<Name>& name);
    string getName() const { return this->varName->name(); }

    void setTypeTag(const shared_ptr<TypeTag>& typeTag);
    shared_ptr<TypeTag> getTypeTag() { return this->typeTag; }

    void setInitExpr(const shared_ptr<Ast>& expr);
    shared_ptr<Ast> getInitExpr() { return initExpr; }

    void setSymbol(Compiler::Symbol symbol) { mSymbol = symbol; }
    Compiler::Symbol getSymbol() { return mSymbol; }

    int32_t accept(Compiler::Visitor* visitor) override;
};

} // namespace Parser

#endif // PARSER_VAR_DEF_STMT_H
